package com.maple.common.utils

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.text.TextUtils
import com.maple.common.R
import com.maple.common.toast.TipsToast

/**
 * Tip:
 * Create by SeVen on 2024/4/7 16:31
 */
object ClipUtils {
    private fun ClipUtils() {
        throw UnsupportedOperationException("can't create instance")
    }

    fun copyText(context: Context, text: String) {
        //1. 复制字符串到剪贴板管理器
        val cmb = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
        cmb.setPrimaryClip(ClipData.newPlainText(null, text))
        if (!TextUtils.isEmpty(text.trim { it <= ' ' })) {
            TipsToast.showSuccessTips(R.string.toast_copy_ok)
        }
    }
}